package com.farshine.baokan.box;

public enum CommandTyep {
    None(0, ""),
    Zhishideng(1, "控制指示灯"),
    Shumaguan(2, "控制数码管"),
    Mensuo(3, "控制门锁打开"),
    Pingmu_shezhiTupian(4, "设置屏幕图片"),
    Pingmu_xianshiTupian(5, "屏幕显示图片"),
    Pingmu_xianshiWenben(6, "屏幕显示文本"),
    System_reboot(7, "系统软启动"),
    Fengmingqi(8, "蜂鸣器控制命令"),
    Pingmu_kongzhi(9, "屏幕控制命令"),
    Chaxun_zhuangtai(20, "查询从机状态");

    private String commandName;
    private int    commandNumber;

    CommandTyep(int number, String name) {
        this.commandNumber = number;
        this.commandName = name;
    }

    public int getNumber() {
        return this.commandNumber;
    }

    @Override
    public String toString() {
        return this.commandName;
    }

    public static CommandTyep fromIndex(Integer commandNumber) {
        if (commandNumber==null) return None;
        for(CommandTyep item : CommandTyep.values()) {
            if (commandNumber.equals(item.commandNumber)){
                return item;
            }
        }
        return None;
    }
}
